package me.jessyan.armscomponent.app.di.module;

import android.view.View;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.di.scope.ActivityScope;

import java.util.ArrayList;
import java.util.List;

import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import me.jessyan.armscomponent.app.mvp.contract.learn.MyReciteContract;
import me.jessyan.armscomponent.app.mvp.model.entity.recite;
import me.jessyan.armscomponent.app.mvp.model.learn.MyReciteModel;
import me.jessyan.armscomponent.app.mvp.ui.adapter.ReciteAdapter;


/**
 * ================================================
 * Description:
 * <p>
 * Created by MVPArmsTemplate on 08/27/2021 22:27
 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
 * <a href="https://github.com/JessYanCoding">Follow me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
 * <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
 * ================================================
 */
@Module
public abstract class MyReciteModule {

    @Binds
    abstract MyReciteContract.Model bindMyReciteModel(MyReciteModel model);

    @ActivityScope
    @Provides
    static RecyclerView.LayoutManager provideLayoutManager(MyReciteContract.View view) {
        return new LinearLayoutManager(view.getActivity());
    }

    @ActivityScope
    @Provides
    static List<recite> provideList() {
        return new ArrayList<>();
    }

    @ActivityScope
    @Provides
    static RecyclerView.Adapter provideZhihuHomeAdapter(MyReciteContract.View zhihuHomeView, List<recite> list){
        ReciteAdapter adapter = new ReciteAdapter(list);
        adapter.setOnItemClickListener(new DefaultAdapter.OnRecyclerViewItemClickListener<recite>() {
            @Override
            public void onItemClick(View view, int viewType, recite recite, int position) {
                //跳转到详情
                /*ARouter.getInstance()
                        .build(RouterHub.ZHIHU_DETAILACTIVITY)
                        .withInt(ZhihuConstants.DETAIL_ID, data.getId())
                        .withString(ZhihuConstants.DETAIL_TITLE, data.getTitle())
                        .navigation(zhihuHomeView.getActivity());*/
            }
        });
        return adapter;
    }
}